package com.sdhs.common.utils.mqtt;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;

/**
 * 既是消息也是chat
 * @author cqp1116
 * @date
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class MqttMessageDTO<T> implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 消息ID
     */
    @ApiModelProperty(value = "消息ID")
    private String id;

    @ApiModelProperty(value = "消息类型")
    private  String msgType;

    /**
     * 标题
     */
    @ApiModelProperty(value = "消息标题")
    private String title;

    /**
     * 消息来源
     */
    @ApiModelProperty(value = "发送人")
    private  String from;

    /**
     * 目的用户类型 ALL 所有人 LONGIN 当前用户
     * USER指定用户  逗号,表示多用户
     * TOKEN  指定token  逗号,表示token
     * ROLE 用户角色  逗号,表示多角色
     * BIZ_ROLE  用户业务角色 逗号,表示多角色
     * GROUP 群组
     * ROLE BIZ_ROLE GROUP 暂不支持
     */
    @ApiModelProperty(value = "接收人类型 ALL USER TOKEN")
    private  String toType;
    /**
     * 消息目的
     */
    @ApiModelProperty(value = "接收人 多人逗号分隔")
    private  String to;

    /**
     * 数据 发送的消息
     */
    @ApiModelProperty(value ="消息数据")
    private  T data;
    /**
     * 发送时间
     */
    @ApiModelProperty(value ="发送时间")
    private Date sendTime;

    public MqttMessageDTO(T data){
        this.data=data;
        this.sendTime=new Date();
    }

    public MqttMessageDTO(String from,String to,T data){
        this.data=data;
        this.from=from;
        this.to= to;
        this.msgType = "9";
        this.sendTime=new Date();
    }

    public MqttMessageDTO(String from,String to,String msgType ,T data){
        this.from=from;
        this.to= to;
        this.data=data;
        this.msgType = msgType;
        this.sendTime=new Date();
    }
    public MqttMessageDTO(String type,String from,String to,String msgType ,T data){
        this.from=from;
        this.to= to;
        this.data=data;
        this.msgType = msgType;
        this.sendTime=new Date();
    }

}
